import sun.security.ec.CurveDB;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

/**
 * Created by MGL on 2017/5/6.
 */
public class Test01 {
    public void test() {
        ClassLoader loader1 = ClassLoader.getSystemClassLoader();
        ClassLoader loader2 = loader1.getParent();
        CurveDB db = new CurveDB();
        System.out.println(db.getClass().getClassLoader());
        System.out.println(loader1);//AppClassLoader
        System.out.println(loader2);//ExtClassLoader
        String s = new String();
        ClassLoader loader3 = s.getClass().getClassLoader();
        System.out.println(loader3);
    }

    public void test01() throws ClassNotFoundException {
        ClassLoader loader1 = this.getClass().getClassLoader();
        System.out.println(loader1);
        Class<?> clazz = loader1.loadClass("java.lang.String");
        System.out.println(clazz);
    }

    public void test03() throws IllegalAccessException, InstantiationException {
        Class clazz = User.class;
        Field[] declaredFields = clazz.getDeclaredFields();

        for (Field declaredField : declaredFields) {
            int i = declaredField.getModifiers();
            String s = Modifier.toString(i);
            System.out.println(s);
        }
    }

    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        Test01 test01 = new Test01();
//        test01.test();
        test01.test03();
//        String str = "aa";
//        Class clazz1 = str.getClass();
//
//        Class clazz2 = String.class;
//
//        Class clazz3 = Class.forName("java.lang.String");
//        System.out.println(clazz1);
//        System.out.println(clazz1 == clazz2);
//        System.out.println(clazz1 == clazz3);
//
//
//        System.out.println(Integer.class == int.class);
//
//        System.out.println(Integer.TYPE == int.class);
//
//
//        Class clazz4 = void.class;
//        System.out.println(clazz4.isPrimitive());


    }
}
